﻿using RAP.Framework.Libary.DataSource.Context;
using RAP.Framework.Libary.DataSource.Model;
using RAP.Framework.Libary.DataSource.Model.DataSource;
using RAP.Framework.Libary.DomTemplateBuilder.Interface;
using RAP.Framework.Libary.SqlTaskParser;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;

namespace RAP.Framework.Libary.DataSource
{
  /// <summary>
  /// 
  /// </summary>
  public interface IDataSourceService
  {
    /// <summary>
    /// /
    /// </summary>
    DataSourceConfig DataConfigration { get; set; }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="param"></param>
    /// <param name="result"></param>
    /// <param name="context">上下文对象</param>
    /// <returns></returns>
    Task<bool> InvokeService(IQueryParams param, IQueryResult result, IDataServiceContext context = null);

    /// <summary>
    /// 
    /// </summary>
    /// <param name="param"></param>
    /// <param name="result"></param>
    /// <param name="context"></param>
    /// <returns></returns>
    bool InvokeServiceSync(IQueryParams param, IQueryResult result, IDataServiceContext context = null);

    /// <summary>
    /// 执行一个查询子任务
    /// </summary>
    /// <param name="task"></param>
    /// <param name="param"></param>
    /// <param name="context"></param>
    int RunServiceTask(SqlTask task, IQueryParams param, IDataServiceContext context);

    /// <summary>
    /// 解析IDataReader的数据
    /// </summary>
    /// <param name="reader"></param>
    /// <param name="parseContext">解析时用到的上下文对象</param>
    /// <param name="totalDataCount"></param>
    /// <param name="resultAlias"></param>
    /// <param name="defaultDataType"></param>
    /// <returns></returns>
    IDictionary ParseData(IDataReader reader, DataParseContext parseContext, out int totalDataCount, string defaultDataType = null, IList<string> resultAlias = null, IDictionary resultObject = null);
  }
}